package com.jianganming.state.pay;

//支付
public class PayOrderState implements IState {
    private Context context = Context.getContext();

    private IState iState;

    public PayOrderState(IState iState) {
        if(iState instanceof LogisticsOrderState || iState instanceof RefundOrderState){
            this.iState = iState;
        }else {
            throw new RuntimeException("下一个环节是物流或者退款");
        }
    }

    @Override
    public void doAction(Order order) {
        System.out.println("支付成功，订单号："+order.getOrderNumber()+" 商品："+order.getProductName()+" 支付金额："+order.getPrice());
        context.addOrderState(OrderState.pay_order);
        iState.doAction(order);//调用下一个环节
    }
}
